﻿using LaserMark.DataAccess.Models;

namespace LaserMark.DataAccess.Service
{
    public class MachineService : IMachineService
    {
        private IDBManager DBManager { get; set; }

        public MachineService(IDBManager dBManager)
        {
            DBManager = dBManager;
        }

        public async Task<MachineSetting> GetMachine(string key)
        {
            using var db = DBManager.Create();
            return await db.SingleAsync<MachineSetting>("where key = @0", key);
        }

        public async Task<bool> UpdateMachine(IEnumerable<MachineSetting> model)
        {
            using var db = DBManager.Create();
            foreach (var item in model)
            {
                await db.UpdateAsync(item);
            }
            return true;
        }
    }
}
